package me.idashu.attg.service;

import java.util.List;
import java.util.Map;

import me.idashu.attg.domain.MemberEntity;
import me.idashu.attg.persistence.MemberMapper;
import me.idashu.attg.util.MD5Encode;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class MemberService {

	@Autowired
	private MemberMapper memberMapper;

	public void insertCode(MemberEntity entity) {

		memberMapper.insertCode(entity);
	}

	public MemberEntity selectMember(int id) {
		return memberMapper.selectMember(id);
	}

	public void deleteMember(int id) {
		memberMapper.deleteMember(id);
	}

	public void updateMember(MemberEntity entity) {
		memberMapper.updateMember(entity);
	}


	public MemberEntity loginMember(MemberEntity entity) {
		
		return memberMapper.loginMember(entity);
	}

	
	public MemberEntity getMember(MemberEntity entity){
		return memberMapper.getMember(entity);
	}
	
	public void updateCode(MemberEntity entity){
		memberMapper.updateCode(entity);
	}
	
	public List<MemberEntity>  getMemberEntityByPage(Map<String, Object> map){
		List<MemberEntity> listMember = memberMapper.getMemberEntityByPage(map);
		return listMember;
	}
	
	public int getCountMemberEntityByPage(MemberEntity memberEntity){
		int count = memberMapper.getCountMemberEntityByPage(memberEntity);
		return count;
	}

	public void insertMemberEntity(MemberEntity memberEntity){
		String encodePass = MD5Encode.Md5(memberEntity.getMember_Pass());
		memberEntity.setMember_Pass(encodePass);
		memberMapper.insertMemberEntity(memberEntity);
	}
	
	public MemberEntity getMemberEntityByName(String memberName){
		MemberEntity memberEntity = memberMapper.getMemberEntityByName(memberName);
		return memberEntity;
	}
	public void modifyMember(MemberEntity memberEntity){
		 memberMapper.modifyMember(memberEntity);
	}
	
	public void modifyAvater(MemberEntity memberEntity){
		 memberMapper.modifyAvater(memberEntity);
	}
	
	public List<MemberEntity> getSearchMember(MemberEntity memberEntity){
		List<MemberEntity> listMember = memberMapper.getSearchMember(memberEntity);
		return listMember;
	}
}
